//
//  YZNetworkManager+oneYuan.m
//  YZMicroStock
//
//  Created by apple on 16/12/8.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZClient+oneYuan.h"


@implementation YZNetworkManager (oneYuan)

- (void)oneY_getConfigureDataSuccess:(void (^)(NSURLResponse *response,id responseObject))success failure: (void (^)(NSError *error))failure{
    [self.mainNetwork cq_noCachePOST:URL_FOR_FETCH_ONEY_CONFIGURE_DATA parameters:@{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE} success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}


- (void)oneY_createStrategyWithParams:(NSMutableDictionary *)dic success:(void (^)(NSURLSessionDataTask *task,id responseObject))success failure: (void (^)(NSError *error))failure {
    
    NSDictionary *params = @{@"volumeOrder":dic[@"amount"],
                             @"stockCode":dic[@"stockCode"],
                             @"token":dic[@"token"],
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE,};
    [self.mainNetwork cq_noCachePOST:URL_FOR_CREATE_ONEY_STRATERY parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}

-(void)oneY_getSaleListFirstWithParamsuccess:(void (^)(NSURLSessionDataTask *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params = @{
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE,};
    [self.mainNetwork cq_noCachePOST:URL_FOR_FIRST_FETCH_SALELIST_ABOUT_ONEY parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}


-(void)oneY_getSaleListMemcaWithParamsuccess:(void (^)(NSURLSessionDataTask *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params = @{
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE,};
    [self.mainNetwork cq_noCachePOST:URL_FOR_MEMCA_SALELIST_ABOUT_ONEY parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}

- (void)oneY_getSettleListWithParamsuccess:(void (^)(NSURLSessionDataTask *task,id responseObject))success failure: (void (^)(NSError *error))failure{
    NSDictionary *params = @{
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE,};
    [self.mainNetwork cq_noCachePOST:URL_FOR_FETCH_SETTLELIST_ABOUT_ONEY parameters:params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}


-(void)oneY_closeTradeWithID:(long long)tid andAlwaysCloseFlag:(BOOL)alwaysCloseFlag success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    NSDictionary *params = @{@"id":@(tid),
                             @"isAlwaysClose": alwaysCloseFlag?@"true":@"false",
                             COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    [self.mainNetwork cq_noCachePOST:URL_FOR_SALE_STRATEGY_ABOUT_ONEY parameters:params success:^(NSURLSessionDataTask *task, id responseObject) {
        if (success) {
            success(task.response, responseObject);
        }
    }failure:^(NSURLSessionDataTask *task, NSError *error) {
        if (failure) {
            failure(error);
        }
    }];
}

@end
